//
//  AiFPassportRegAndBindAccountManager.m
//  PywSdk
//
//  Created by Jade on 16/8/31.
//  Copyright © 2016年 zero. All rights reserved.
//

#import "AiFPassportRegAndBindAccountManager.h"
#import "PywRSAUtil.h"

@implementation AiFPassportRegAndBindAccountManager

const NSString *bing_Account = @"account";
const NSString *bing_Token = @"token";
const NSString *bing_Passport = @"passport";
const NSString *bing_PassportPwd = @"passport_pwd";
const NSString *bing_Tid = @"tid";
const NSString *bing_Sign = @"sign";

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.child = self;
        self.paramSource = self;
        self.validate = self;
    }
    return self;
}


#pragma mark - ETAPIManager
- (NSString *)methodName
{
    return URL_PASSPORTREGANDBINDACCOUNT;
}

- (ETAPIManagerRequestType)requestType
{
    return ETAPIManagerRequestTypePost;
}


- (NSString *)seriviceType
{
    return [PywAppInfo sharedAppInfo].seriviceType;
}


#pragma mark - ETAPIManagerParamSourceDelegate
- (NSDictionary *)paramsForApi:(ETApiBaseManager *)manager{
    NSString *_tid = [PywAppInfo sharedAppInfo].tid;
    NSString *_gameid = [PywAppInfo sharedAppInfo].gameId;
    NSString *_apiSecret2 = [AppUtil getApiSecret2:_tid apiSecret:[PywAppInfo sharedAppInfo].apisecret];
    NSString *_account = [PywPlatformMain sharedPlatformMain].account;
    NSString *_token = [PywPlatformMain sharedPlatformMain].token;
    NSString *_passport = self.passport;
    NSString *_passport_pwd = [PywRSAUtil encryptString:self.passport_pwd];
    NSString *_sign = [NSString stringWithFormat:@"%@%@%@%@", _gameid,_account,_passport,_apiSecret2];
    _sign = [PywCipherUtils md5:_sign];
    
    MutableDictionary *param = [[MutableDictionary alloc] init];
    [param setObject:_account forKey:bing_Account];
    [param setObject:_token forKey:bing_Token];
    [param setObject:_passport forKey:bing_Passport];
    [param setObject:_passport_pwd forKey:bing_PassportPwd];
    [param setObject:_tid forKey:bing_Tid];
    [param setObject:_sign forKey:bing_Sign];
    return param;
}



#pragma mark - ETAPIManagerValidator
- (BOOL)manager:(ETApiBaseManager *)manager isCorrectWithParamsData:(NSDictionary *)data{
    return YES;
}

- (BOOL)manager:(ETApiBaseManager *)manager isCorrectWithCallBackData:(NSDictionary *)data{
    return YES;
}
@end
